package network.exercise.exercise3;

import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-04-07
 * Time:21:50
 */
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket(InetAddress.getLocalHost(),9999);
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        Scanner scanner = new Scanner(System.in);
        String question = scanner.nextLine();
        bw.write(question);
        bw.flush();
        socket.shutdownOutput();
        InputStream inputStream = socket.getInputStream();
        FileOutputStream fos = new FileOutputStream("f:/Test/"+question+".mp3");
        byte[] bytes = inputStream.readAllBytes();
        fos.write(bytes);
        fos.close();
        socket.close();
    }
}
